using System;
using System.Data;
using System.Data.SqlClient;
using LibreriaCommon;
using LibreriaData;
using Microsoft.Practices.EnterpriseLibrary.Data;
using SistemaControlTraficoLibDS;

namespace SistemaControlTraficoLibData
{
    public class daReserva : daReservaBase, IDisposable
    {
        public daReserva(SecurityInfo securityInfo) : base(securityInfo)
        {
        }

        public DataSet FindByFiltros(string ClienteRazonSocial, int TipoMovilID, Nullable<DateTime> FechaDesde, Nullable<DateTime> FechaHasta, bool SoloProximasASalir, object estado)
        {
            try
            {
                DataSet ds = new DataSet();
                daCommon.GenericFind(securityInfo, "ReservaFindByFiltros", ds, new string[] { "Reserva" }, ClienteRazonSocial, TipoMovilID, FechaDesde, FechaHasta, SoloProximasASalir, estado);
                return ds;
            }
            catch (Exception ex)
            {
                throw new daException(ex);
            }
        }
        public DataSet FindByDay()
        {
            try
            {
                DataSet ds = new DataSet();
                daCommon.GenericFind(securityInfo, "ReservaFindByDay", ds, new string[] { "Reserva" });
                return ds;
            }
            catch (Exception ex)
            {
                throw new daException(ex);
            }
        }

        public void Desactivar(int reservaID)
        {
            try
            {
                daCommon.ExecuteNonQuery(securityInfo, "ConnectionString", "ReservaDesactivar", reservaID);
            }
            catch (Exception ex)
            {
                throw new daException(ex);
            }
        }

        public int FindProximosASalir()
        {
            try
            {
                DataSet ds = new DataSet();
                daCommon.GenericFind(securityInfo, "ReservaFindProximosASalir", ds, new string[] { "Reserva" });

                return int.Parse(ds.Tables[0].Rows[0]["Cantidad"].ToString());
            }
            catch (Exception ex)
            {
                throw new daException(ex);
            }
        }

    }
}

